package com.example.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.Mycoupon;
import com.example.service.IMycouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kk
 * @since 2024-07-02
 */
@Controller
@RequestMapping("/mycoupon")
public class MycouponController {
    //个人所有优惠券
    @Autowired
    private IMycouponService service;
    //查询当前登陆用户所有优惠券
    @GetMapping("all")
    @ResponseBody
    public List<Mycoupon> getAll(){
        //完整业务当中，用户的id从http request head 获得登陆用户信息（JWT），
        // 现在只能使用假数据
        Integer customerId=901;
        List<Mycoupon> mycouponList=service.getByCustomerId(customerId);
        return mycouponList;
    }
    @GetMapping("/status/{status}")
    @ResponseBody
    public List<Mycoupon> getByStatus(@PathVariable("status") Integer couponStatus){
        Integer customerId=901;
        List<Mycoupon> mycouponList=service.getByStatus(customerId,couponStatus);
        return mycouponList;
    }
}
